home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / WAIS / next-ui / DocControl.h < prev    next >
Encoding:
Text File  |  1992-02-03  |  2.5 KB  |  90 lines

  1. // DocControl.h
  2. //
  3. // Free software created 1 Feb 1992
  4. // by Paul Burchard <burchard@math.utah.edu>.
  5. //
  6. // Provides an abstract superclass to act as App's delegate and handle
  7. // opening and closing of documents.  You'll connect Document menu items
  8. // in IB to target their messages to this object.
  9. //
  10. // The subclass do the following in its -init method:
  11. //
  12. //    * Give -setDocHandlers: a List of Doc subclasses (this list will
  13. //        be freed by the DocControl class when it's done with it).
  14. //    * Set launchWithCreateDoc to YES, if you want the app to launch with
  15. //        an newly created open document (except when explicitly
  16. //        launched by an openFile:: message).  This will use the first 
  17. //        Doc handler in the list.
  18. //
  19. // Most subclasses will probably also want to subclass the method
  20. //
  21. //    + (const char *)defaultFolder    Default folder for Open/Save Panels,
  22. //                    when Doc subclass is unknown.
  23. //
  24. // Also, the stringTable points to an NXStringTable (to be created in IB)
  25. // translating the following strings:
  26. //    "/UNTITLED"
  27. //    "Revert"
  28. //    "Revert to saved version of %s?"
  29. //    "Close"
  30. //    "%s has been modified.\nSave it?"
  31. //    "Open"
  32. //    "Cannot read %s!"
  33. //    "Save"
  34. //    "Cannot write %s!"
  35. //    "Yes"
  36. //    "No"
  37. //    "OK"
  38. //    "Cancel"
  39. //
  40.  
  41. #import <objc/Object.h>
  42. #import <objc/HashTable.h>
  43. #import <objc/NXStringTable.h>
  44.  
  45. @interface DocControl:Object
  46. {
  47.     id DocHandlers;
  48.     const char **fileTypes;
  49.     BOOL launchWithCreateDoc;
  50.     id convertWindowToDoc;
  51.     id stringTable;
  52. }
  53.  
  54. - init;
  55. - setDocHandlers:HandlerList;
  56. - appDidInit:sender;
  57. - free;
  58. + (const char *)defaultFolder;
  59. - appWillTerminate:sender;
  60. - (BOOL)appAcceptsAnotherFile:sender;
  61. - handlerForFile:(const char *)fileName;
  62. - (int)app:sender openFile:(const char *)fileName type:(const char *)aType;
  63. - setMainDoc:aDoc;
  64. - mainDoc;
  65. - stringTable;
  66.  
  67. // Basic Doc operations.
  68. // All return the Doc on success (except -closeDoc:andFree: returns self).
  69. - createDocForHandlerAt:(int)hNum;
  70. - openForHandlerAt:(int)hNum name:(const char *)fileName;//may be NULL
  71. - saveDoc:theDoc as:(BOOL)yn;
  72. - revertDocToSaved:theDoc;
  73. - closeDoc:theDoc andFree:(BOOL)yn;
  74.  
  75. // Menu items.
  76. - open:sender; // allows all file types, determines handler afterwards
  77. - open1:sender; // uses first handler
  78. - open2:sender; // uses second handler
  79. - open3:sender; // uses third handler
  80. - createDoc:sender; // uses default (=first) handler
  81. - createDoc1:sender; // uses first handler
  82. - createDoc2:sender; // uses second handler
  83. - createDoc3:sender; // uses third handler
  84. - saveAs:sender;
  85. - save:sender;
  86. - revertToSaved:sender;
  87. - close:sender;
  88.  
  89. @end
  90.